/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 compound_object.h

	$Header: /heroes4/compound_object.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( COMPOUND_OBJECT_H_INCLUDED )
#define COMPOUND_OBJECT_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "compound_object_model_ptr.h"
#include "combat_saveable_object.h"
#include "idle_processor.h"
#include "map_point.h"
#include "map_rect.h"

#include <vector>
class  t_battlefield;
class  t_combat_object_model_cache;
struct t_map_point_2d;
class  t_stationary_combat_object;

typedef std::vector<t_stationary_combat_object*> t_stationary_combat_object_array;

// -----------------------------------------------------------------------
// class which contains several object segments
// -----------------------------------------------------------------------
class t_compound_object : public t_combat_saveable_object, public t_idle_processor
{
public:
	t_compound_object();
	t_compound_object( t_battlefield& );
	t_compound_object( t_combat_object_model_cache const& model_cache );

	void									enable_animation( bool arg );
	virtual t_combat_object_type			get_object_type() const;
	t_stationary_combat_object_array const& get_objects() const;
	t_map_rect_2d							get_cell_rect() const;
	bool									is_removed() const;
	bool									is_underlay() const;
	virtual void							on_idle();
	virtual void							place( t_battlefield&		 battlefield,
												   t_map_point_2d const& point );
	void									place_segment( t_battlefield& battlefield, 
														   t_stationary_combat_object* object );
	virtual bool							read( t_combat_reader& reader );
	virtual void							remove( t_battlefield& battlefield );
	void									set_underlay( t_battlefield& battlefield, bool arg );
	virtual bool							write( t_combat_writer& writer ) const;
protected:
	bool								m_animating;
	bool								m_is_underlay;
	t_compound_object_model_ptr			m_model;
	std::string							m_model_name;
	t_map_point_3d						m_position;
	bool								m_removed;
	t_stationary_combat_object_array	m_segments;
};

inline bool t_compound_object::is_removed() const
{
	return m_removed;
}

inline t_stationary_combat_object_array const& t_compound_object::get_objects() const
{
	return m_segments;
}

inline bool t_compound_object::is_underlay() const
{
	return m_is_underlay;
}

#endif // COMPOUND_OBJECT_H_INCLUDED